import {allPages, menuPages} from "@/views/Pages/index.js";

// 手动配置的嵌套路由
const customMenus = [
    // {
    //     path: "/afterSales",
    //     meta: {title: "售后列表", icon: "el-icon-receiving",authorityList: 700},
    //     component: () => import("@/views/Pages/afterSales.vue"),
    // },
     {
        path: "/talent",
        meta: {title: "入驻管理", icon: "el-icon-cpu", authorityList: 1400},
        children: [
            {
                path: "/talentPool",
                name: "TalentPool",
                meta: {title: "人才库", authorityList: 1401},
                component: () => import("@/views/Pages/talentPool.vue"),
            },
        ],
    },
    {
        path: "/company",
        meta: {title: "公司/供应商", icon: "el-icon-suitcase-1",authorityList: 300},
        children: [
            // {
            //     path: "/supplierList",
            //     name: "SupplierList",
            //     meta: {title: "供应商列表",authorityList: 311},
            //     component: () => import("@/views/Pages/supplierList.vue"),
            // },
            {
                path: "/companyList",
                name: "companyList",
                meta: {title: "公司列表", authorityList: 301},
                component: () => import("@/views/Pages/companyList.vue"),
            },
        ],
    }, {
        path: "/wareHouse",
        meta: {title: "仓库/库存/材料", icon: "el-icon-price-tag",authorityList: 1500},
        children: [
            {
                path: "/warehouseList",
                name: "WarehouseList",
                meta: {title: "仓库列表", authorityList: 1501},
                component: () => import("@/views/Pages/warehouseList.vue"),
            }, {
                path: "/inventoryInventoryList",
                name: "InventoryInventoryList",
                meta: {title: "库存列表", authorityList: 1511},
                component: () => import("@/views/Pages/inventoryInventoryList.vue"),
            }, {
                path: "/materialList",
                name: "MaterialList",
                meta: {title: "材料列表", authorityList: 1521},
                component: () => import("@/views/Pages/materialList.vue"),
            },
        ],
    }, {
        path: "/user",
        meta: {title: "人员/角色", icon: "el-icon-user",authorityList: 500},
        children: [
            {
                path: "/userList",
                name: "userList",
                meta: {title: "人员列表", authorityList: 501},
                component: () => import("@/views/Pages/userList.vue"),
            }, {
                path: "/roleList",
                name: "roleList",
                meta: {title: "角色列表", authorityList: 511},
                component: () => import("@/views/Pages/roleList.vue"),
            },
        ],
    },
    {
        path: "/patrolSOP",
        name: "patrolSOP",
        meta: {title: "巡查SOP", icon: "el-icon-suitcase-1", authorityList: 989}, // authorityList
        children: [
            {
                path: "/patrolSOP",
                name: "patrolSOP",
                meta: {title: "巡查SOP", icon: "el-icon-suitcase-1"},
                component: () => import("@/views/Pages/patrolSOP.vue"),
            },
            {
                path: "/patrolSetting",
                name: "patrolSetting",
                meta: {title: "配置", icon: "el-icon-edit-outline", showInMenu: false},
                component: () => import("@/views/Pages/innerPages/patrolSetting.vue"),
            }, {
                path: "/addInspection",
                name: "addInspection",
                meta: {title: "配置", icon: "el-icon-edit-outline", showInMenu: false},
                component: () => import("@/views/Pages/innerPages/addInspection.vue"),
            },
        ]
    },
    {
        path: "/patrol",
        meta: {title: "巡查配置", icon: "el-icon-search", authorityList: 1700},
        children: [
            {
                path: "/dailyPatrol",
                name: "dailyPatrol",
                meta: {title: "在线考评", icon: "el-icon-edit-outline",authorityList: 1710},
                component: () => import("@/views/Pages/dailyPatrol.vue"),
            }, {
                path: "/startAssessment",
                name: "startAssessment",
                meta: {title: "配置", icon: "el-icon-edit-outline", showInMenu: false,},
                component: () => import("@/views/Pages/innerPages/startAssessment.vue"),
            }, {
                path: "/assessmentDetail",
                name: "assessmentDetail",
                meta: {title: "考评详情", icon: "el-icon-edit-outline", showInMenu: false},
                component: () => import("@/views/Pages/innerPages/assessmentDetail.vue"),
            }, {
                path: "/unQualifyDetail",
                name: "unQualifyDetail",
                meta: {title: "不合格", icon: "el-icon-edit-outline", showInMenu: false},
                component: () => import("@/views/Pages/innerPages/unQualifyDetail.vue"),
            }, {
                path: "/pictrueCenter",
                name: "pictrueCenter",
                meta: {title: "图片中心", icon: "el-icon-edit-outline",authorityList: 1720},
                component: () => import("@/views/Pages/pictrueCenter.vue"),
            }, {
                path: "/autoPic",
                name: "autoPic",
                meta: {title: "自动抓图配置", icon: "el-icon-edit-outline",authorityList: 1730},
                component: () => import("@/views/Pages/autoPic.vue"),
            }, {
                path: "/addAutoPic",
                name: "addAutoPic",
                meta: {title: "自动抓图配置", icon: "el-icon-edit-outline", showInMenu: false},
                component: () => import("@/views/Pages/innerPages/addAutoPic.vue"),
            }, {
                path: "/planConfiguration",
                name: "planConfiguration",
                meta: {title: "巡查计划配置", icon: "el-icon-edit-outline",authorityList: 1740},
                component: () => import("@/views/Pages/planConfiguration.vue"),
            }, {
                path: "/planStatistics",
                name: "planStatistics",
                meta: {title: "巡查计划统计", icon: "el-icon-edit-outline",authorityList: 1750},
                component: () => import("@/views/Pages/planStatistics.vue"),
            },
        ],
    },
    // {
    //     path: "/aiPatrol",
    //     meta: {title: "AI巡查", icon: "el-icon-link", authority: 400},
    //     children: [
    //         {
    //             path: "/aiSetting",
    //             name: "aiSetting",
    //             meta: {title: "AI点检配置", icon: "el-icon-edit-outline"},
    //             component: () => import("@/views/Pages/aiSetting.vue"),
    //         }, {
    //             path: "/aiStatistics",
    //             name: "aiStatistics",
    //             meta: {title: "点检统计", icon: "el-icon-edit-outline"},
    //             component: () => import("@/views/Pages/aiStatistics.vue"),
    //         }, {
    //             path: "/aiProblemDetail",
    //             name: "aiProblemDetail",
    //             meta: {title: "点检问题明细", icon: "el-icon-edit-outline"},
    //             component: () => import("@/views/Pages/aiProblemDetail.vue"),
    //         },
    //     ],
    // },
    {
        path: "/patrolAnalyze",
        meta: {title: "巡查分析", icon: "el-icon-aim", authorityList: 1600},
        children: [
            {
                path: "/patrolAnalyze",
                name: "patrolAnalyze",
                meta: {title: "巡查概览", icon: "el-icon-edit-outline",authorityList: 1601},
                component: () => import("@/views/Pages/patrolAnalyze.vue"),
            }, {
                path: "/pendingTodo",
                name: "pendingTodo",
                meta: {title: "巡查概览", icon: "el-icon-edit-outline", showInMenu: false},
                component: () => import("@/views/Pages/pendingTodo.vue"),
            },
            // {
            //     path: "/areaReport",
            //     name: "areaReport",
            //     meta: {title: "区域报表", icon: "el-icon-edit-outline"},
            //     component: () => import("@/views/Pages/areaReport.vue"),
            // },
        ],
    },

];

export const menuRoutes = [
    ...allPages,
    ...customMenus.flatMap(menu => menu.children || [])
];

// 只显示 showInMenu !== false 的
export const visibleMenus = [
    ...menuPages,
    ...customMenus.map(menu => {
        if (menu.children) {
            return {
                ...menu,
                children: menu.children.filter(child => child.meta?.showInMenu !== false),
            };
        }
        return menu.meta?.showInMenu !== false ? menu : null;
    }).filter(Boolean)
];
export default visibleMenus;
